package o;

import android.os.Parcelable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import java.lang.reflect.Method;

@RestrictTo({d.LIBRARY_GROUP_PREFIX})
public abstract class pb {
    protected final ds<String, Method> ˎ;
    protected final ds<String, Method> ˏ;
    protected final ds<String, Class> ॱ;

    protected abstract CharSequence ʻ();

    protected abstract <T extends Parcelable> T ʼ();

    protected abstract byte[] ʽ();

    protected abstract pb ˊ();

    protected abstract void ˊ(int i);

    protected abstract void ˊ(Parcelable parcelable);

    protected abstract void ˊ(boolean z);

    protected abstract int ˋ();

    protected abstract void ˋ(CharSequence charSequence);

    protected abstract String ˎ();

    protected abstract void ˏ();

    protected abstract void ˏ(int i);

    protected abstract void ॱ(String str);

    protected abstract void ॱ(byte[] bArr);

    protected abstract boolean ॱ(int i);

    protected abstract boolean ॱॱ();

    public pb(ds<String, Method> dsVar, ds<String, Method> dsVar2, ds<String, Class> dsVar3) {
        this.ˎ = dsVar;
        this.ˏ = dsVar2;
        this.ॱ = dsVar3;
    }

    public boolean ॱ() {
        return false;
    }

    public void ॱ(boolean z, boolean z2) {
    }

    public void ˊ(boolean z, int i) {
        ˏ(i);
        ˊ(z);
    }

    public void ˏ(byte[] bArr, int i) {
        ˏ(i);
        ॱ(bArr);
    }

    public void ॱ(CharSequence charSequence, int i) {
        ˏ(i);
        ˋ(charSequence);
    }

    public void ˏ(int i, int i2) {
        ˏ(i2);
        ˊ(i);
    }

    public void ˏ(String str, int i) {
        ˏ(i);
        ॱ(str);
    }

    public void ˏ(Parcelable parcelable, int i) {
        ˏ(i);
        ˊ(parcelable);
    }

    public boolean ॱ(boolean z, int i) {
        return !ॱ(i) ? z : ॱॱ();
    }

    public int ˊ(int i, int i2) {
        return !ॱ(i2) ? i : ˋ();
    }

    public String ˋ(String str, int i) {
        return !ॱ(i) ? str : ˎ();
    }

    public byte[] ॱ(byte[] bArr, int i) {
        return !ॱ(i) ? bArr : ʽ();
    }

    public <T extends Parcelable> T ˎ(T t, int i) {
        return !ॱ(i) ? t : ʼ();
    }

    public CharSequence ˏ(CharSequence charSequence, int i) {
        return !ॱ(i) ? charSequence : ʻ();
    }

    public void ˎ(pd pdVar, int i) {
        ˏ(i);
        ˏ(pdVar);
    }

    public void ˏ(pd pdVar) {
        if (pdVar == null) {
            ॱ(null);
            return;
        }
        ˊ(pdVar);
        pb ˊ = ˊ();
        ˎ(pdVar, ˊ);
        ˊ.ˏ();
    }

    private void ˊ(pd pdVar) {
        try {
            ॱ(ˎ(pdVar.getClass()).getName());
        } catch (Throwable e) {
            throw new RuntimeException(pdVar.getClass().getSimpleName() + " does not have a Parcelizer", e);
        }
    }

    public <T extends pd> T ˏ(T t, int i) {
        return !ॱ(i) ? t : ᐝ();
    }

    public <T extends pd> T ᐝ() {
        String ˎ = ˎ();
        if (ˎ == null) {
            return null;
        }
        return ॱ(ˎ, ˊ());
    }

    protected <T extends pd> T ॱ(String str, pb pbVar) {
        try {
            return (pd) ˏ(str).invoke(null, new Object[]{pbVar});
        } catch (Throwable e) {
            throw new RuntimeException("VersionedParcel encountered IllegalAccessException", e);
        } catch (Throwable e2) {
            if (e2.getCause() instanceof RuntimeException) {
                throw ((RuntimeException) e2.getCause());
            }
            throw new RuntimeException("VersionedParcel encountered InvocationTargetException", e2);
        } catch (Throwable e22) {
            throw new RuntimeException("VersionedParcel encountered NoSuchMethodException", e22);
        } catch (Throwable e222) {
            throw new RuntimeException("VersionedParcel encountered ClassNotFoundException", e222);
        }
    }

    protected <T extends pd> void ˎ(T t, pb pbVar) {
        try {
            ॱ(t.getClass()).invoke(null, new Object[]{t, pbVar});
        } catch (Throwable e) {
            throw new RuntimeException("VersionedParcel encountered IllegalAccessException", e);
        } catch (Throwable e2) {
            if (e2.getCause() instanceof RuntimeException) {
                throw ((RuntimeException) e2.getCause());
            }
            throw new RuntimeException("VersionedParcel encountered InvocationTargetException", e2);
        } catch (Throwable e22) {
            throw new RuntimeException("VersionedParcel encountered NoSuchMethodException", e22);
        } catch (Throwable e222) {
            throw new RuntimeException("VersionedParcel encountered ClassNotFoundException", e222);
        }
    }

    private Method ˏ(String str) throws IllegalAccessException, NoSuchMethodException, ClassNotFoundException {
        Method method = (Method) this.ˎ.get(str);
        if (method != null) {
            return method;
        }
        System.currentTimeMillis();
        method = Class.forName(str, true, pb.class.getClassLoader()).getDeclaredMethod("read", new Class[]{pb.class});
        this.ˎ.put(str, method);
        return method;
    }

    private Method ॱ(Class cls) throws IllegalAccessException, NoSuchMethodException, ClassNotFoundException {
        Method method = (Method) this.ˏ.get(cls.getName());
        if (method != null) {
            return method;
        }
        Class ˎ = ˎ(cls);
        System.currentTimeMillis();
        method = ˎ.getDeclaredMethod("write", new Class[]{cls, pb.class});
        this.ˏ.put(cls.getName(), method);
        return method;
    }

    private Class ˎ(Class<? extends pd> cls) throws ClassNotFoundException {
        Class cls2 = (Class) this.ॱ.get(cls.getName());
        if (cls2 != null) {
            return cls2;
        }
        cls2 = Class.forName(String.format("%s.%sParcelizer", new Object[]{cls.getPackage().getName(), cls.getSimpleName()}), false, cls.getClassLoader());
        this.ॱ.put(cls.getName(), cls2);
        return cls2;
    }
}
